
set ( MOAB_MESQUITE_SRCS  MsqMOAB.cpp )
set ( MOAB_MESQUITE_LIB_INCLUDES MsqMOAB.hpp )

set(IMESQUITE_LINK_LIBS )

if (ENABLE_CGM)
  include_directories( ${CGM_INCLUDE_DIRS} )
  set(IMESQUITE_LINK_LIBS ${IGEOM_LIBS} ${CGM_LIBRARIES})
  set(MOAB_MESQUITE_SRCS ${MOAB_MESQUITE_SRCS} MsqIGeom.cpp )
  set(MOAB_MESQUITE_LIB_INCLUDES ${MOAB_MESQUITE_LIB_INCLUDES} MsqIGeom.hpp )
endif()

if (ENABLE_IMESH)
  include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/src/itaps/imesh ${CMAKE_CURRENT_BINARY_DIR}/src/itaps/imesh )
  set(IMESQUITE_LINK_LIBS iMesh ${IMESQUITE_LINK_LIBS})
  set(MOAB_MESQUITE_SRCS ${MOAB_MESQUITE_SRCS} MsqIMesh.cpp )
  set(MOAB_MESQUITE_LIB_INCLUDES ${MOAB_MESQUITE_LIB_INCLUDES} MsqIMesh.hpp )

if (MOAB_HAVE_MPI)
  include_directories( ${MPI_INCLUDE_DIRS} )
  set(IMESQUITE_LINK_LIBS ${MPI_LIBRARIES})

  set(MOAB_MESQUITE_SRCS ${MOAB_MESQUITE_SRCS} MsqIMeshP.cpp )
  set(MOAB_MESQUITE_LIB_INCLUDES ${MOAB_MESQUITE_LIB_INCLUDES} MsqIMeshP.hpp )
endif()

endif()

if (ENABLE_IREL)
  include_directories( ${CGM_INCLUDE_DIRS} )
  set(IMESQUITE_LINK_LIBS ${IMESQUITE_LINK_LIBS} ${IGEOM_LIBS} ${CGM_LIBRARIES})

  set(MOAB_MESQUITE_SRCS iRel ${MOAB_MESQUITE_SRCS} MsqIRel.cpp )
  set(MOAB_MESQUITE_LIB_INCLUDES ${MOAB_MESQUITE_LIB_INCLUDES} MsqIRel.hpp )
endif()

set(IMESQUITE_LINK_LIBS MOAB ${IMESQUITE_LINK_LIBS})
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/src
  ${CMAKE_SOURCE_DIR}/src
  ${CMAKE_SOURCE_DIR}/itaps
  ${CMAKE_BINARY_DIR}/itaps
  )

if ( MOAB_HAVE_HDF5 AND HDF5_FOUND )
  include_directories( ${HDF5_INCLUDE_DIRECTORIES}
                       ${CMAKE_SOURCE_DIR}/src/io/mhdf/include )
endif( )

set_source_files_properties(
  ${MOAB_MESQUITE_SRCS} COMPILE_FLAGS "${MOAB_DEFINES}"
  )

add_library(
  MsqITAPS
  ${MOAB_MESQUITE_SRCS}
  ${MOAB_MESQUITE_LIB_INCLUDES}
  )

target_link_libraries( MsqITAPS ${IMESQUITE_LINK_LIBS} )

set_target_properties(
  MsqITAPS
  PROPERTIES
  VERSION ${MOAB_VERSION}
  SOVERSION ${MOAB_VERSION_MAJOR}
  )

install(
  TARGETS MsqITAPS
  EXPORT MOABTargets
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  )
set( MOAB_INSTALL_TARGETS ${MOAB_INSTALL_TARGETS} MsqITAPS)

install(
  FILES ${MOAB_MESQUITE_LIB_INCLUDES}
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  )

